﻿using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using OpenLS.Core.Notification;

namespace OpenLS.Spreadsheet.UI
{
    abstract class FormatterBase : ViewModelBase
    {
        private bool _dirty;

        public bool IsDirty
        {
            get { return _dirty; }
            protected set { _dirty = value; }
        }

        protected void SetDirty()
        {
            _dirty = true;
        }
        public void Apply(Range selection)
        {
            if (!_dirty)
                return;
            ApplyOverride(selection);
        }
        protected abstract void ApplyOverride(Range selection);
       
       
        public void NotifyDirtyPropertyChanged(string propertyName)
        {
            notifyPropertyChanged(propertyName);
            SetDirty();
        }
    }
}